package la.iok.hzsvn.lewin.movie.controller;

import la.iok.hzsvn.lewin.movie.core.model.PlayRoleInstVo;
import la.iok.hzsvn.lewin.movie.entity.MovieInstance;
import la.iok.hzsvn.lewin.movie.service.MovieInstanceService;
import la.iok.hzsvn.lewin.movie.service.PlayRoleInstanceService;
import la.iok.hzsvn.share.response.SingleDataResponse;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("internal-api/playRoleInstances")
public class PlayRoleInstanceInternalController {
    private final PlayRoleInstanceService playRoleInstanceService;
    private final MovieInstanceService movieInstanceService;

    public PlayRoleInstanceInternalController(PlayRoleInstanceService playRoleInstanceService,
                                              MovieInstanceService movieInstanceService) {
        this.playRoleInstanceService = playRoleInstanceService;
        this.movieInstanceService = movieInstanceService;
    }

    @GetMapping("movie/{movieId}/v/{version}/playRole/{id}")
    public SingleDataResponse<PlayRoleInstVo> inst(@PathVariable Long movieId, @PathVariable String version, @PathVariable Long id){
        MovieInstance mi = movieInstanceService.movieInst2(movieId,version);
        return new SingleDataResponse<>(playRoleInstanceService.select(mi.getId(),id));
    }
}
